package com.fanbuchi.app.ins.service;

import com.fanbuchi.app.ins.api.AuthAPI;

import com.fanbuchi.app.ins.net.Scope;
import com.fanbuchi.app.ins.vo.auth.Auth;
import com.fanbuchi.app.ins.vo.auth.Introspect;
import com.fanbuchi.app.ins.vo.enums.GrantType;

import rx.Observable;

/**
 * Created by rabbit on 2016/3/21.
 */
public class AuthService extends BaseServcice{

    public static Observable<Auth> oauth(String userName,String password){
        Observable<Auth> responseObservable=createAPI(AuthAPI.class).oauth(userName, password, GrantType.password.name(), Scope.read_write);
        return asyncService(responseObservable);
    }


    public static Observable<Auth> refreshToken(String refresh_token){
        Observable<Auth> responseObservable=createAPI(AuthAPI.class).refreshToken(GrantType.refresh_token.name(),refresh_token);
        return asyncService(responseObservable);
    }


    public static Observable<Introspect> introspect(String token){
        Observable<Introspect> responseObservable=createAPI(AuthAPI.class).introspect(GrantType.access_token.name(),token);
        return asyncService(responseObservable);
    }
}
